package com.zly.dockercompose.controller;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BookController {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/book")
    public String book() {
        return stringRedisTemplate.opsForValue().get("book");
    }

    @RequestMapping("/add/{book}")
    public String add(@PathVariable String book) {
        stringRedisTemplate.opsForValue().set("book", book);
        return "ok";
    }
}